/**
 * 
 */
package com.alisoft.kplan.api.lottery.dao.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alisoft.kplan.api.lottery.bo.Question;
import com.alisoft.kplan.api.lottery.bo.QuestionResult;
import com.alisoft.kplan.api.lottery.dao.IQuestionDao;

/**
 * @author Administrator
 * 
 */
public class QuestionDao extends SqlMapClientDaoSupport implements IQuestionDao {
	
	public Question getLotteryQuestion(String phaseId, Date publishDate,
			String publishSn) {
		Map<String, String> params = new HashMap<String, String>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		params.put("phaseId", phaseId);
		params.put("publishDate", sdf.format(publishDate));
		params.put("publishSn", publishSn);
		return (Question) getSqlMapClientTemplate().queryForObject(
				"getQuestionByPdDateSn", params);
	}

	@SuppressWarnings("unchecked")
	public List<QuestionResult> getQuestionResultByQuestionId(String questionId) {
		return (List<QuestionResult>) getSqlMapClientTemplate().queryForList(
				"getQuestionResultByQuestionId", questionId);
	}

	public Question getLotteryQuestion(String questionId) {
		return (Question)getSqlMapClientTemplate().queryForObject("getQuestionByQuestionId",questionId);
	}

	public QuestionResult getQuestionResult(String resultId) {
		return (QuestionResult)getSqlMapClientTemplate().queryForObject("getQuestionResultByResultId",resultId);
	}

	
}
